import './login.scss';
import { useNavigate } from 'react-router-dom';
const Login = () => {
  const navigate=useNavigate()
  let username = ''
  let pass = ''
  // 获取账号
  const usernameChange = (e) => {
    username=e.target.value
    console.log(username);
  }
  // 获取密码
  const passChange = (e) => {
    pass=e.target.value
    console.log(pass);
  }
  // 登录
  const loginEnter = () => {
    navigate('/home')
    // let data={
    //   username,
    //   pass
    // }
    // localStorage.setItem('username', JSON.stringify(data))
  }
    return (
      <div className='background'>
        <div className='box'>
          <h2 className='title'>登录</h2>
          <div className='username'>
            <input type="text" ref={input=>username=input} onChange={usernameChange} className='account' placeholder='username' />
          </div>
          <div className='pwd'>
            <input type="text" ref={input=>pass=input} onChange={passChange} className='password' placeholder='Password' />
          </div>
          <button onClick={loginEnter}>登录</button>
        </div>
      </div>
    )
}

export default Login;